package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author wz
 * @description:
 * @date 2021-10-31
 */
@Configuration("UserService")
public class UserServiceImpl implements UserService {

    @Value("${jdbc.userName}")
    private String userName;

    @Value("${jdbc.password}")
    private String password;

    @Autowired
    private UserDao userDao;

//    @Qualifier("UserDao1")
//    private UserDao userDao;

    @Override
    public void add() {
//        System.out.println("user add run..." + " " + userName + " " + password);
        userDao.add();
    }
    @PostConstruct
    public void initService(){
        System.out.println("init run...");
    }

    @PreDestroy
    public void destoryService() {
        System.out.println("destory run...");
    }
}
